#include "../../include/car_parts/ladar.h"
Ladar::Ladar()
{
    this->model = "RS-Helios-16p";
    this->channels = 16;
    this->maxRange = 100;
    this->powerConsumed = 8;
}
void Ladar::setModel(const std::string &model)
{
    this->model = model;
}

void Ladar::setChannels(int channels)
{
    this->channels = channels;
}

void Ladar::setMaxRange(double maxRange)
{
    this->maxRange = maxRange;
}

void Ladar::setPowerConsumed(double powerConsumed)
{
    this->powerConsumed = powerConsumed;
}
// 屏幕输出
void Ladar::print()
{
    std::cout << "**雷达模块**"
              << "\n雷达通道数: " << channels << "\n雷达测试范围(m): " << maxRange << "\n多线激光雷达型号: " << model << "\n雷达功耗(W): " << powerConsumed << std::endl;
}
// 本地文件保存
void Ladar::save(const std::string &filename)
{
    // 打开一个输出文件流
    std::ofstream file(filename, std::ios::app);
    if (!file.is_open())
    {
        std::cout << "未找到文件！" << std::endl;
        return;
    }

    file << "," << channels << "," << maxRange << "," << model << "," << powerConsumed;

    // 关闭文件流
    file.close();
}